package a3_p04_ak_fh_test;

import static org.junit.Assert.assertEquals;

import java.util.HashSet;
import java.util.Set;

import org.jgrapht.WeightedGraph;
import org.jgrapht.graph.DefaultWeightedEdge;
import org.junit.Test;

import a2_p04_ak_fh.AttVertex;
import a2_p04_ak_fh.IOHelper;
import a3_p04_ak_fh.Kruskal;

public class KruskalTest {
	
	@Test
	public void testGraph4() {

		System.out.println("Test Graph4");
		
		IOHelper IOHelper = new IOHelper();
		
		WeightedGraph<AttVertex, DefaultWeightedEdge> graph = IOHelper.readGraphFile("graph4.gka");
		
		Kruskal minGraph = Kruskal.CalcPriQu(graph);
		
		assertEquals(true,minGraph.getGraph().vertexSet().containsAll(graph.vertexSet()));
		assertEquals("wrong weight sum", 27.0, minGraph.getWeightSum(),0.1);
	}

	@Test
	public void testGraph4FibHeap() {

		System.out.println("Test Graph4 FibHeap");
		
		IOHelper IOHelper = new IOHelper();
		
		WeightedGraph<AttVertex, DefaultWeightedEdge> graph = IOHelper.readGraphFile("graph4.gka");
		
		Kruskal minGraph = Kruskal.CalcFibHeap(graph);
		
		assertEquals(true,minGraph.getGraph().vertexSet().containsAll(graph.vertexSet()));
		assertEquals("wrong weight sum", 27.0, minGraph.getWeightSum(),0.1);
	}
	
	@Test
	public void testGraph5() {

		System.out.println("Test Graph5");
		
		IOHelper IOHelper = new IOHelper();
		
		WeightedGraph<AttVertex, DefaultWeightedEdge> graph = IOHelper.readGraphFile("graph5.gka");
		
		Kruskal minGraph = Kruskal.CalcPriQu(graph);
		
		assertEquals("wrong weight sum", 17.0, minGraph.getWeightSum(),0.1);
	}
	@Test
	public void testGraph5FibHeap() {

		System.out.println("Test Graph5 FibHeap");
		
		IOHelper IOHelper = new IOHelper();
		
		WeightedGraph<AttVertex, DefaultWeightedEdge> graph = IOHelper.readGraphFile("graph5.gka");
		
		Kruskal minGraph = Kruskal.CalcFibHeap(graph);
		
		assertEquals("wrong weight sum", 17.0, minGraph.getWeightSum(),0.1);
	}

}
